home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / telecomm / 532 / sttalker / demo.bts < prev    next >
Text File  |  1991-11-28  |  12KB  |  380 lines

  1. // STalker 3 script file for disabled demo
  2.  
  3.  
  4. include "stalker.bth"       // definitions for built-in functions
  5.  
  6. function show_fkeys()       // show function key assignments
  7.   string  buffer[80];
  8.   int   i;
  9.  
  10.   i = 0;
  11.   repeat
  12.     set_int_param(MISC_PARAM, SHOW_CONTROL_CHARS, TRUE);  // display controls
  13.     printf("fkey%02d = \"%s\"", i + 1,
  14.          get_string_param(FKEY_PARAM, i, buffer, sizeof(buffer)));
  15.     set_int_param(MISC_PARAM, SHOW_CONTROL_CHARS, FALSE);
  16.     puts("\r\n");
  17.   until (i = i + 1) >= 20;
  18.   putchar('\n');
  19. endfunction
  20.  
  21.  
  22. function show_logon(
  23.   int   entry_num
  24.   )                         // display the automatic logon entries
  25.   int   i;
  26.   int   print_title;
  27.   string  prompt[10];
  28.   string  response[30];
  29.  
  30.   print_title = TRUE;
  31.   i = 0;
  32.   repeat
  33.     get_string_param(DIALER_LOGON_PARAM, entry_num + ((DIALER_LG_PROMPT + i) << 16), prompt, sizeof(prompt));
  34.     if get_int_param(DIALER_LOGON_PARAM, entry_num + ((DIALER_LG_HIDDEN + i) << 16)) then
  35.       strcpy(response, "«Hidden»");     // it's a hidden string (password)
  36.     else
  37.       get_string_param(DIALER_LOGON_PARAM, entry_num + ((DIALER_LG_RESPONSE + i) << 16), response, sizeof(response));
  38.     endif
  39.     if prompt[0] OR response[0] then
  40.       if print_title then
  41.         puts("        Prompt     Response\r\n");
  42.         puts("        ---------  -----------------------------\r\n");
  43.         print_title = FALSE;
  44.       endif
  45.       set_int_param(MISC_PARAM, SHOW_CONTROL_CHARS, TRUE);
  46.       printf("        %-11.9s%s", prompt, response);
  47.       set_int_param(MISC_PARAM, SHOW_CONTROL_CHARS, FALSE);
  48.       puts("\r\n");
  49.     endif
  50.   until (i = i + 1) >= 8;
  51.   putchar('\n');
  52. endfunction
  53.  
  54.  
  55. function show_dialer()      // display autodialer entries
  56.   int   group;
  57.   int   i;
  58.   int   count;
  59.   string  name[20];
  60.   string  number[20];
  61.   string  script[10];
  62.  
  63.   i = 0;
  64.   count = 0;
  65.   repeat
  66.     get_string_param(DIALER_NAME_PARAM, i, name, sizeof(name));
  67.     get_string_param(DIALER_NUMBER_PARAM, i, number, sizeof(number));
  68.  
  69.     if name[0] OR number[0] then
  70.       if (count = count+1) == 1 then        // only the first time around
  71.         puts("BBS/Service Name     Group     Phone Number      $$/Hr  Limit   Script\r\n");
  72.         puts("-------------------  -----  -------------------  -----  -----  --------\r\n");
  73.       endif
  74.       group = get_int_param(DIALER_GROUP_PARAM, i);
  75.       if group < 0 then
  76.         group = ' ';
  77.       else
  78.         group = group + '0';
  79.       endif
  80.       get_string_param(DIALER_SCRIPT_PARAM, i, script, sizeof(script));
  81.       printf("%-23.19s%c    %-19.19s  %2d.%02d  %2d.%02d  %s\r\n",
  82.            name, group, number,
  83.            get_int_param(DIALER_COST_PARAM, i) / 100, get_int_param(DIALER_COST_PARAM, i) % 100,
  84.            get_int_param(DIALER_LIMIT_PARAM, i) / 100, get_int_param(DIALER_LIMIT_PARAM, i) % 100,
  85.            script
  86.           );
  87.  
  88.       show_logon(i);
  89.     endif
  90.   until (i = i + 1) >= 30;
  91.   if count == 0 then        // no entries
  92.     puts("Oh, it doesn't look like you have any dialer entries set.\r\n");
  93.   endif
  94. endfunction
  95.  
  96.  
  97. function show_modem()       // show the modem configuration settings
  98.   string  buf[80];
  99.   int   i;
  100.  
  101.   set_int_param(MISC_PARAM, SHOW_CONTROL_CHARS, TRUE);
  102.   printf("Modem Init: «%s»", get_string_param(MDM_INIT_PARAM, 0, buf, sizeof(buf)));
  103.   set_int_param(MISC_PARAM, SHOW_CONTROL_CHARS, FALSE);
  104.   puts("\r\n");
  105.  
  106.   set_int_param(MISC_PARAM, SHOW_CONTROL_CHARS, TRUE);
  107.   printf("    Prefix: «%s»", get_string_param(MDM_PREFIX_PARAM, 0, buf, sizeof(buf)));
  108.   set_int_param(MISC_PARAM, SHOW_CONTROL_CHARS, FALSE);
  109.   puts("\r\n");
  110.  
  111.   set_int_param(MISC_PARAM, SHOW_CONTROL_CHARS, TRUE);
  112.   printf("    Suffix: «%s»", get_string_param(MDM_SUFFIX_PARAM, 0, buf, sizeof(buf)));
  113.   set_int_param(MISC_PARAM, SHOW_CONTROL_CHARS, FALSE);
  114.   puts("\r\n");
  115.  
  116.   set_int_param(MISC_PARAM, SHOW_CONTROL_CHARS, TRUE);
  117.   printf("    Hangup: «%s»", get_string_param(MDM_HANGUP_PARAM, 0, buf, sizeof(buf)));
  118.   set_int_param(MISC_PARAM, SHOW_CONTROL_CHARS, FALSE);
  119.   puts("\r\n");
  120.  
  121.   i = 0;
  122.   repeat
  123.     set_int_param(MISC_PARAM, SHOW_CONTROL_CHARS, TRUE);
  124.     printf("  Connect%d: «%s»", i + 1, get_string_param(MDM_CONNECT_PARAM, i, buf, sizeof(buf)));
  125.     set_int_param(MISC_PARAM, SHOW_CONTROL_CHARS, FALSE);
  126.     puts("\r\n");
  127.   until (i = i + 1) >= 2;
  128.  
  129.   i = 0;
  130.   repeat
  131.     set_int_param(MISC_PARAM, SHOW_CONTROL_CHARS, TRUE);
  132.     printf("     Fail%d: «%s»", i + 1, get_string_param(MDM_FAILURE_PARAM, i, buf, sizeof(buf)));
  133.     set_int_param(MISC_PARAM, SHOW_CONTROL_CHARS, FALSE);
  134.     puts("\r\n");
  135.   until (i = i + 1) >= 4;
  136.  
  137.   printf("Use DCD: %d   Use DTR: %d   Character Delay: %d\r\n",
  138.        get_int_param(MDM_USE_DCD_PARAM, 0), get_int_param(MDM_USE_DTR_PARAM, 0),
  139.        get_int_param(MDM_DELAY_PARAM, 0));
  140. endfunction
  141.  
  142.  
  143. function show_path()    // display STalker's file paths
  144.   string  buf[256];
  145.  
  146.   printf("Download Path: %s\r\n", get_string_param(PATH_PARAM, PATH_DOWNLOAD, buf, sizeof(buf)));
  147.   printf("  Script Path: %s\r\n", get_string_param(PATH_PARAM, PATH_SCRIPT  , buf, sizeof(buf)));
  148.   printf(" General Path: %s\r\n", get_string_param(PATH_PARAM, PATH_GENERAL , buf, sizeof(buf)));
  149.   printf("   Scrap Path: %s\r\n", get_string_param(PATH_PARAM, PATH_SCRAP   , buf, sizeof(buf)));
  150. endfunction
  151.  
  152.  
  153. function waitkey()      // wait for a key to be pressed
  154.   puts( "\r\n\r\nPress any key to continue..." );
  155.   getchar();
  156. endfunction
  157.  
  158.  
  159. function show_settings()    // show all of the settings
  160.   puts( "\033ETo start with, here are the function key strings:\r\n\n" );
  161.   show_fkeys();
  162.   waitkey();
  163.   puts( "\033EAnd here are your autodialer settings:\r\n\n" );
  164.   show_dialer();
  165.   waitkey();
  166.   puts( "\033EThis is the modem configuration:\r\n\n" );
  167.   show_modem();
  168.   waitkey();
  169.   puts( "\033EAnd these are the current paths:\r\n\n" );
  170.   show_path();
  171.   waitkey();
  172. endfunction
  173.  
  174. //  Test all of the possible colour combinations allowed by
  175. //  VT52 and VT100/ANSI emulations.
  176. function show_colors()
  177.   int   orig_emulation;
  178.   string  s;
  179.  
  180.   orig_emulation = get_emulation();     // save emulation
  181.   s = "This text is being written with the colour set to ";
  182.  
  183.   set_emulation(EMUL_VT52);     // force to VT-52
  184.  
  185.   puts("\033E\t\t\033b1\033p        VT52 Mode        \033q\r\n");
  186.   printf("\033b0%sWHITE\r\n", s);
  187.   printf("\033b1%sBLACK\r\n", s);
  188.   printf("\033b2%sRED\r\n", s);
  189.   printf("\033b3%sGREEN\r\n", s);
  190.   printf("\033b4%sBLUE\r\n", s);
  191.   printf("\033b5%sCYAN\r\n", s);
  192.   printf("\033b6%sYELLOW\r\n", s);
  193.   printf("\033b7%sMAGENTA\r\n", s);
  194.   printf("\033b8%sLIGHT WHITE (LIGHT GREY)\r\n", s);
  195.   printf("\033b9%sLIGHT BLACK (GREY)\r\n", s);
  196.   printf("\033b:%sLIGHT RED\r\n", s);
  197.   printf("\033b;%sLIGHT GREEN\r\n", s);
  198.   printf("\033b<%sLIGHT BLUE\r\n", s);
  199.   printf("\033b=%sLIGHT CYAN\r\n", s);
  200.   printf("\033b>%sLIGHT YELLOW\r\n", s);
  201.   printf("\033b?%sLIGHT MAGENTA\r\n", s);
  202.  
  203.  
  204.   puts("\n\t\t\033b1\033p     VT100/ANSI Mode     \033q\r\n");
  205.   set_emulation(EMUL_VT100);
  206.  
  207.   printf("\23337m%sWHITE\r\n", s);
  208.   printf("\23330m%sBLACK\r\n", s);
  209.   printf("\23331m%sRED\r\n", s);
  210.   printf("\23332m%sGREEN\r\n", s);
  211.   printf("\23333m%sYELLOW\r\n", s);
  212.   printf("\23334m%sBLUE\r\n", s);
  213.   printf("\23335m%sMAGENTA\r\n", s);
  214.   printf("\23336m%sCYAN\r\n", s);
  215.  
  216.   printf("\23330m");  // Restore colour to BLACK
  217.  
  218.   set_emulation(orig_emulation);    // restore emulation
  219. endfunction
  220.  
  221. //  Tests the play_sound() builtin function.
  222. function show_tunes()
  223.     string  buffer[80];
  224.  
  225.     puts("\033E");
  226.     while TRUE do
  227.         puts("Sound number to play (0-5, Return to exit) -> ");
  228.         if gets(buffer, sizeof(buffer)) <= 0 then
  229.             return;
  230.         endif
  231.         play_sound(atoi(buffer));
  232.     endwhile
  233. endfunction
  234.  
  235.  
  236. //  Copy a file to the STalker terminal window.
  237. function show_file(string file)
  238.     string  buffer[256];
  239.     int     fd;
  240.  
  241.     if (fd = file_open(file, 0)) < 0 then
  242.         printf("Error %d opening '%s'\r\n", fd, file);
  243.         return;
  244.     endif
  245.  
  246.     while file_gets(buffer, sizeof(buffer), fd) > 0 do
  247.         puts(buffer);
  248.     endwhile
  249.  
  250.     file_close(fd);
  251. endfunction
  252.  
  253.  
  254. function show_a_file()
  255.     string  source_file[14];
  256.     string  source_full[128];
  257.     string  source_path[128];
  258.  
  259.     source_path[0] = file_get_drive();
  260.     source_path[1] = ':';
  261.     file_get_dir(0, source_path + 2);
  262.     strcat(source_path, "\\*.*");
  263.     source_file[0] = 0;
  264.  
  265.     if fsel(source_path, source_file, source_full, "File to Display?") then
  266.         if source_file[0] == 0 then
  267.             return;
  268.         endif
  269.  
  270.         puts("\033E");
  271.         show_file(source_full);
  272.     endif
  273.     waitkey();
  274. endfunction
  275.  
  276. //  Tests the file_dir_first/next() builtin routines by showing a directory
  277. function show_dir()
  278.     string  buffer[24];
  279.     string  temp[80];
  280.     int     chars;
  281.     int     f_attr;
  282.     int     f_time;
  283.     int     f_date;
  284.     int     f_size;
  285.     string  f_name;         // Pointer into 'buffer' at file name
  286.     int     subdir;
  287.     int     success;
  288.  
  289.     puts( "\033EEnter the path (with wildcards) to get the directory for.\r\n\
  290. Example:  C:\\*.*\r\n-> " );
  291.     chars = gets( temp, sizeof(temp) );
  292.     if chars==0 then
  293.       return;
  294.     endif
  295.     puts("Attr Time  Date  FileSize FileName\r\n");
  296.     success = file_dir_first(temp, 0x31, buffer);
  297.     while success do
  298.         f_attr = buffer[0];
  299.         f_time = (buffer[1] << 8)  | buffer[2];
  300.         f_date = (buffer[3] << 8)  | buffer[4];
  301.         f_size = (buffer[5] << 24) | (buffer[6] << 16) | (buffer[7] << 8) | buffer[8];
  302.         f_name = buffer + 9;
  303.  
  304.         if f_attr BITAND 0x10 then
  305.             subdir = '\\';
  306.         else
  307.             subdir = ' ';
  308.         endif
  309.  
  310.         printf(" %02x  ", f_attr );
  311.         strftime(temp, sizeof(temp), "%H:%M %m/%d", (f_date<<16) | f_time);
  312.         printf("%s %8d %s%c\r\n", temp, f_size, f_name, subdir);
  313.         success = file_dir_next(buffer);
  314.     endwhile
  315.     waitkey();
  316. endfunction
  317.  
  318.  
  319. // The fun begins here!
  320. function main()
  321.   int emulation;
  322.   int key;
  323.   int time;
  324.   int valid;
  325.  
  326.   emulation = get_emulation();  // save emulation
  327.   set_emulation(0);             // and set to VT100
  328.   puts( "\033E\tWelcome to the STalker 3 demonstration!\r\n\n\
  329. This script will show you just some of the capabilities\r\n\
  330. of the BackTALK script language. List the file DEMO.BTS\r\n\
  331. to see what this script looks like.\r\n\n\n" );
  332.   time = 0;
  333.   repeat
  334.     if (time = time+1) > 1 then
  335.       puts( "\033E" );          // clear screen after first time through
  336.     endif
  337.     puts("Please choose an option from the menu below:\r\n\n\
  338.  \t\033p1\033q Show STalker's settings\r\n\
  339.  \t\033p2\033q Show VT-100/PC-ANSI colors\r\n\
  340.  \t\033p3\033q Play the built-in tunes\r\n\
  341.  \t\033p4\033q Show a text file\r\n\
  342.  \t\033p5\033q Get disk directory\r\n\
  343.  \t\033pQ\033q Quit this demo\r\n\r\n" );
  344.     valid = FALSE;
  345.     repeat
  346.       key = getchar();
  347.       if key == '1' then
  348.         show_settings();
  349.         valid = TRUE;
  350.       else
  351.         if key == '2' then
  352.           show_colors();
  353.           valid = TRUE;
  354.         else
  355.           if key == '3' then
  356.             show_tunes();
  357.             valid = TRUE;
  358.           else
  359.             if key == '4' then
  360.               show_a_file();
  361.               valid = TRUE;
  362.             else
  363.               if key == '5' then
  364.                 show_dir();
  365.                 valid = TRUE;
  366.               else
  367.                 if (key&0x5F) == 'Q' then
  368.                   puts( "\r\n\r\nThank you for running the demo!\r\n\r\n" );
  369.                   set_emulation(emulation); // restore old emulation
  370.                   return;
  371.                 endif
  372.               endif
  373.             endif
  374.           endif
  375.         endif
  376.       endif
  377.     until valid;
  378.   until FALSE;
  379. endfunction
  380.